﻿<%@ Page Language="VB" Debug="true" %>
<%@ Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI" Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

    Sub Page_Load()
        Dim ConnectionString As String = ConfigurationSettings.AppSettings("strcnn")
        Dim strsql As String
        Dim myConnection As New OleDbConnection(ConnectionString)
        Dim cnn as New OleDbConnection(ConnectionString)
        Dim myCommand as New OleDbCommand
        Dim cmd as New OleDbCommand
        Dim myDataReader as OleDbDataReader
        Dim dr as OleDbDataReader
        myConnection.Open()
        cnn.Open()
        myCommand.Connection = myConnection
        cmd.Connection = cnn
    
        select(Request("acao"))
        case "inserir":
            dim vet
            vet = Request.Form("Data").Split("/")
            dim data as String = vet(1) & "/" & vet(0) & "/" & vet(2)
            strsql = "INSERT INTO Pedido ( IDCliente, IDVendedor, IDFabrica, IDTransportadora, Data, CondicaoPagamento, PrazoEntrega, Observacao, Desconto, Faturado, Cancelado, Total, CodigoJolitex, Pecas ) values (" & Request.Form("IDCliente") & ", " & Request.Form("IDVendedor") & ", " & Request.Form("IDFabrica") & ", " & Request.Form("IDTransportadora") & ", #" & iif(Request.Form("Data")="", Format(Today, "dd/MM/yy"), data) & "#, '" & Request.Form("CondicaoPagamento") & "', '" & Request.Form("PrazoEntrega") & "', '" & Request.Form("Observacao") & "', '" & Request.Form("Desconto") & "', " & Request.Form("Faturado") & ", " & Request.Form("Cancelado") & ", " & iif(Request.Form("Total")="", 0, Replace(Request.Form("Total"), ",", ".")) & ", " & iif(Request.Form("CodigoJolitex") = "", 0, Request.Form("CodigoJolitex")) & ", 0)"
            myCommand.CommandText = strsql
            myCommand.ExecuteNonQuery()
            myCommand.CommandText = "select max(id) as id from pedido"
            myDataReader = myCommand.ExecuteReader()
            myDataReader.Read()
            Response.Redirect("pedidoexibiralterar.aspx?acao=exibir&id=" & myDataReader("id"))
        case "alterar":
            dim vet
            vet = Request.Form("Data").Split("/")
            dim data as String = vet(1) & "/" & vet(0) & "/" & vet(2)
            strsql = "update pedido set IDCliente=" & Request.Form("IDCliente") & ", IDVendedor=" & Request.Form("IDVendedor") & ", IDFabrica=" & Request.Form("IDFabrica") & ", IDTransportadora=" & Request.Form("IDTransportadora") & ", Data=#" & iif(Request.Form("Data")="", Format(Today, "dd/MM/yy"), data) & "#, CondicaoPagamento='" & Request.Form("CondicaoPagamento") & "', PrazoEntrega='" & Request.Form("PrazoEntrega") & "', Observacao='" & Request.Form("Observacao") & "', Desconto='" & Request.Form("Desconto") & "', Faturado=" & Request.Form("Faturado") & ", Cancelado=" & Request.Form("Cancelado") & ", Total=" & iif(Request.Form("Total")="", 0, Replace(Request.Form("Total"), ",", ".")) & ", CodigoJolitex=" & iif(Request.Form("CodigoJolitex")="", 0, Request.Form("CodigoJolitex")) & " where id=" & Request.Form("ID")
            myCommand.CommandText = strsql
            myCommand.ExecuteNonQuery()
            Response.Redirect("pedidoexibiralterar.aspx?acao=exibir&id=" & Request.Form("ID"))
        case "inserirproduto":
            strsql = "insert into produto (idpedido, quantidade, codigo, descricao, precounitario) values (" & Request.Form("IDPedido") & ", " & Replace(Request.Form("Quantidade"), ",", ".") & ", '" & Request.Form("Codigo") & "', '" & Request.Form("Descricao") & "', " & Replace(Request.Form("PrecoUnitario"), ",", ".") & ")"
            myCommand.CommandText = strsql
            myCommand.ExecuteNonQuery()
            strsql = "SELECT Sum([Produto]![Quantidade]) as Pecas, Sum([Produto]![Quantidade]*[Produto]![PrecoUnitario]) AS Total FROM Produto WHERE Produto.IDPedido=" & Request("IDPedido")
            myCommand.CommandText = strsql
            myDataReader = myCommand.ExecuteReader()
            myDataReader.Read()
            Dim total as String = Replace(myDataReader("Total"), ",", ".")
            Dim pecas as String = myDataReader("Pecas")
    
            myDataReader.Close()
    
            strsql = "update pedido set pecas=" & pecas & ", total=" & total & " where id=" & Request("IDPedido")
            myCommand.CommandText = strsql
            try
                myCommand.ExecuteNonQuery()
            catch
                strsql = "update pedido set pecas=0, total=0 where id=" & Request("IDPedido")
                myCommand.CommandText = strsql
                myCommand.ExecuteNonQuery()
            end try
    
            Response.Redirect("pedidoexibiralterar.aspx?acao=exibir&id=" & Request.Form("IDPedido"))
        case "excluirproduto":
            strsql = "delete * from produto where id=" & Request.Form("idproduto")
            myCommand.CommandText = strsql
            myCommand.ExecuteNonQuery()
    
            strsql = "SELECT Sum([Produto]![Quantidade]) as Pecas, Sum([Produto]![Quantidade]*[Produto]![PrecoUnitario]) AS Total FROM Produto WHERE Produto.IDPedido=" & Request("IDPedido")
            myCommand.CommandText = strsql
            myDataReader = myCommand.ExecuteReader()
            myDataReader.Read()
            Dim total as String = Replace(myDataReader("Total"), ",", ".")
            Dim pecas as String = myDataReader("Pecas")
    
            myDataReader.Close()
    
            strsql = "update pedido set pecas=" & pecas & ", total=" & total & " where id=" & Request("IDPedido")
            myCommand.CommandText = strsql
            try
                myCommand.ExecuteNonQuery()
            catch
                strsql = "update pedido set pecas=0, total=0 where id=" & Request("IDPedido")
                myCommand.CommandText = strsql
                myCommand.ExecuteNonQuery()
            end try
    
            Response.Redirect("pedidoexibiralterar.aspx?acao=exibir&id=" & Request.Form("IDPedido"))
        case "duplicar":
            strsql = "select * from pedido where id=" & Request("id")
            myCommand.CommandText = strsql
            myDataReader = myCommand.ExecuteReader()
            myDataReader.Read()
            dim dataa as String = DateTime.Now.ToShortDateString()
            strsql = "INSERT INTO Pedido ( IDCliente, IDVendedor, IDFabrica, IDTransportadora, Data, CondicaoPagamento, PrazoEntrega, Observacao, Desconto, Faturado, Cancelado, Total, CodigoJolitex ) values (" & myDataReader("IDCliente") & ", " & myDataReader("IDVendedor") & ", " & myDataReader("IDFabrica") & ", " & myDataReader("IDTransportadora") & ", #" & dataa & "#, '" & myDataReader("CondicaoPagamento") & "', '" & myDataReader("PrazoEntrega") & "', '" & myDataReader("Observacao") & "', '" & myDataReader("Desconto") & "', " & myDataReader("Faturado") & ", " & myDataReader("Cancelado") & ", " & Replace(myDataReader("Total"), ",", ".") & ", " & myDataReader("CodigoJolitex") & ")"
            myDataReader.Close()
            myCommand.CommandText = strsql
            myCommand.ExecuteNonQuery()
    
            strsql = "select max(id) as id from pedido"
            myCommand.CommandText = strsql
            myDataReader = myCommand.ExecuteReader()
            myDataReader.Read()
            dim id as integer = myDataReader("id")
            myDataReader.Close()
    
            strsql = "select * from produto where idpedido=" & Request("id")
            myCommand.CommandText = strsql
            myDataReader = myCommand.ExecuteReader()
            while myDataReader.Read()
                strsql = "insert into produto (idpedido, quantidade, codigo, descricao, precounitario) values (" & id & ", " & myDataReader("Quantidade") & ", '" & myDataReader("Codigo") & "', '" & myDataReader("Descricao") & "', " & Replace(myDataReader("PrecoUnitario"), ",", ".") & ")"
                cmd.CommandText = strsql
                cmd.ExecuteNonQuery()
            end while
            myDataReader.Close()
            Response.Redirect("pedidoexibiralterar.aspx?acao=exibir&id=" & id)
        End select
    
        select(Request("acao"))
        case "exibir":
            strsql = "SELECT Pedido.*, Cliente.ID, Cliente.RazaoSocial, Fabrica.ID, Fabrica.RazaoSocial, Transportadora.ID, Transportadora.RazaoSocial, Vendedor.ID, Vendedor.Nome FROM Vendedor INNER JOIN (Transportadora INNER JOIN (Fabrica INNER JOIN (Cliente INNER JOIN Pedido ON Cliente.ID = Pedido.IDCliente) ON Fabrica.ID = Pedido.IDFabrica) ON Transportadora.ID = Pedido.IDTransportadora) ON Vendedor.ID = Pedido.IDVendedor WHERE pedido.id=" & Request("ID")
            myCommand.CommandText = strsql
            myDataReader = myCommand.ExecuteReader()
            myDataReader.Read()
            Dim sinc = myDataReader("Sincronizado")
            Painel.Text = "<h3>Exibir:</h3>" & iif(sinc, "<b><font color='red'>Pedido sincronizado.</font></b><br><br>", "") & "<table border='0' cellspacing='0' cellpadding='4'>"
            sinc = false
            Painel.Text = Painel.Text & "<tr><td>Número:</td><td>" & iif(myDataReader("CodigoJolitex")=0, myDataReader("Pedido.ID"), myDataReader("CodigoJolitex")) & "</td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Cliente:</td><td><a href='cliente.aspx?acao=exibir&id=" & myDataReader("Cliente.ID") & "'>" & myDataReader("Cliente.RazaoSocial") & "</a></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Vendedor:</td><td><a href='vendedor.aspx?acao=exibir&id=" & myDataReader("Vendedor.ID") & "'>" & myDataReader("Nome") & "</a></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Fábrica:</td><td><a href='fabrica.aspx?acao=exibir&id=" & myDataReader("Fabrica.ID") & "'>" & myDataReader("Fabrica.RazaoSocial") & "</a></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Transportadora:</td><td><a href='transportadora.aspx?acao=exibir&id=" & myDataReader("Transportadora.ID") & "'>" & myDataReader("Transportadora.RazaoSocial") & "</a></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Data:</td><td>" & Format(myDataReader("Data"), "dd/MM/yy") & "</td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Cond. pagamento:</td><td>" & myDataReader("CondicaoPagamento") & "</td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Prazo de entrega:</td><td>" & myDataReader("PrazoEntrega") & "</td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Desconto:</td><td>" & myDataReader("Desconto") & "</td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Faturado:</td><td>" & iif(myDataReader("Faturado"), "Sim", "Não") & "</td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Cancelado:</td><td>" & iif(myDataReader("Cancelado"), "Sim", "Não") & "</td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Total:</td><td>R$ " & Format(myDataReader("Total"), "#.00") & "</td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Observação:</td><td>" & myDataReader("Observacao") & "</td></tr>"
            if not sinc then Painel.Text = Painel.Text & "<tr><td><form method='post' action='pedidoexibiralterar.aspx'><input type='hidden' name='acao' value='formalterar'><input type='hidden' name='id' value='" & Request.QueryString("id") & "'><input type='submit' value='Alterar'></form></td>"
            Painel.Text = Painel.Text & "<td><form action='pedido.aspx'><input type='submit' value='Cancelar'><input type='hidden' name='id' value='" & Request.Form("ID") & "'></form></td></tr>"
            if myDataReader("codigojolitex") <> 0 then
                Painel.Text = Painel.Text & "<tr><td><a href='pedidojoliteximprimir.aspx?id=" & myDataReader("codigojolitex") & "'>Imprimir</a></td><td>" & iif(sinc, "", "<a href='pedidoexibiralterar.aspx?acao=duplicar&id=" & Request("id") & "'>Duplicar</a>") & "</td></tr>"
            else
                Painel.Text = Painel.Text & "<tr><td><a href='pedidoimprimir.aspx?id=" & Request("id") & "'>Imprimir</a></td><td>" & iif(sinc, "", "<a href='pedidoexibiralterar.aspx?acao=duplicar&id=" & Request("id") & "'>Duplicar</a>") & "</td></tr>"
            end if
            Painel.Text = Painel.Text & "</table>"
            myDataReader.Close()
            strsql = "select * from produto where idpedido=" & Request("ID")
            myCommand.CommandText = strsql
            myDataReader = myCommand.ExecuteReader()
            Painel.Text = Painel.Text & "<hr><form method='post' action='pedidoexibiralterar.aspx'><table border='0' cellspacing='2' cellpading='2'>"
            Painel.Text = Painel.Text & "<tr bgcolor='#000080'><td><font color='#FFFFFF'><b>Quantidade</b></font></td><td><font color='#FFFFFF'><b>Código</b></font></td><td><font color='#FFFFFF'><b>Descrição</b></font></td><td><font color='#FFFFFF'><b>Preço unitário</b></font></td>" & iif(sinc, "", "<td><font color='#FFFFFF'><b>Excluir</b></font></td>") & "</tr>"
            Dim cor as Boolean
            while myDataReader.Read()
                Painel.Text = Painel.Text & "<tr bgcolor='" & iif(cor, "#ADD8E6", "#E0FFFF") & "'><td>" & myDataReader("Quantidade") & "</td><td>" & myDataReader("Codigo") & "</td><td>" & myDataReader("Descricao") & "</td><td>R$ " & Format(myDataReader("PrecoUnitario"), "#.00") & "</td>" & iif(sinc, "", "<td align='center'><input type='button' value=' ' onClick='vbscript:confirma(" & myDataReader("ID") & ")'></td>") & "</tr>"
                cor = not cor
            End while
            if not sinc then Painel.Text = Painel.Text & "<tr><td><input name='Quantidade'></td><td><input name='Codigo'></td><td><input name='Descricao'></td><td>R$ <input name='PrecoUnitario'></td><td><input type='submit' value='Inserir'></td></tr>"
            Painel.Text = Painel.Text & "</table>"
            Painel.Text = Painel.Text & "<input type='hidden' name='acao' value='inserirproduto'>"
            Painel.Text = Painel.Text & "<input type='hidden' name='IDPedido' value='" & Request("ID") & "'></form>"
            Painel.Text = Painel.Text & "<form name='aux' method='post' action='pedidoexibiralterar.aspx'><input type='hidden' name='acao' value='excluirproduto'><input type='hidden' name='idproduto' value=''><input type='hidden' name='IDPedido' value='" & Request("ID") & "'></form>"
            myDataReader.Close()
        case "formalterar":
            strsql = "select * from pedido where id=" & Request.Form("ID")
            myCommand.CommandText = strsql
            myDataReader = myCommand.ExecuteReader()
            myDataReader.Read()
            Painel.Text = "<h3>Alterar:</h3><form method='post' name='alterar' action='pedidoexibiralterar.aspx'><input type='hidden' name='acao' value='alterar'><input type='hidden' name='id' value='" & myDataReader("ID") & "'><table border='0' cellspacing='0' cellpadding='4'>"
            Painel.Text = Painel.Text & "<tr><td>Número:</td><td>" & myDataReader("ID") & "</td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Código Jolitex:</td><td><input name='CodigoJolitex' value='" & iif(myDataReader("codigojolitex")=0, "", myDataReader("codigojolitex")) & "'></td></tr>"
    
            cmd.CommandText = "select id, razaosocial from cliente order by razaosocial asc"
            dr = cmd.ExecuteReader()
            Painel.Text = Painel.Text & "<tr><td>Cliente:</td><td><select name='IDCliente'>"
                while dr.Read()
                    Painel.Text = Painel.Text & "<option value='" & dr("id") & "'" & iif(dr("id")=myDataReader("idcliente"), "selected", "") & ">" & dr("razaosocial") & "</option>"
                End while
            Painel.Text = Painel.Text & "</select></td></tr>"
            dr.Close()
    
            cmd.CommandText = "select id, nome from vendedor order by nome asc"
            dr = cmd.ExecuteReader()
            Painel.Text = Painel.Text & "<tr><td>Vendedor:</td><td><select name='IDVendedor'>"
                while dr.Read()
                    Painel.Text = Painel.Text & "<option value='" & dr("id") & "'" & iif(dr("id")=myDataReader("idvendedor"), "selected", "") & ">" & dr("nome") & "</option>"
                End while
            Painel.Text = Painel.Text & "</select></td></tr>"
            dr.Close()
    
            cmd.CommandText = "select id, razaosocial from fabrica order by razaosocial asc"
            dr = cmd.ExecuteReader()
            Painel.Text = Painel.Text & "<tr><td>Fábrica:</td><td><select name='IDFabrica'>"
                while dr.Read()
                    Painel.Text = Painel.Text & "<option value='" & dr("id") & "'" & iif(dr("id")=myDataReader("idfabrica"), "selected", "") & ">" & dr("razaosocial") & "</option>"
                End while
            Painel.Text = Painel.Text & "</select></td></tr>"
            dr.Close()
    
            cmd.CommandText = "select id, razaosocial from transportadora order by razaosocial asc"
            dr = cmd.ExecuteReader()
            Painel.Text = Painel.Text & "<tr><td>Transportadora:</td><td><select name='IDTransportadora'>"
                while dr.Read()
                    Painel.Text = Painel.Text & "<option value='" & dr("id") & "'" & iif(dr("id")=myDataReader("idtransportadora"), "selected", "") & ">" & dr("razaosocial") & "</option>"
                End while
            Painel.Text = Painel.Text & "</select></td></tr>"
            dr.Close()
    
            Painel.Text = Painel.Text & "<tr><td>Data:</td><td><input name='Data' value='" & Format(myDataReader("Data"), "dd/MM/yy") & "'></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Cond. pagamento:</td><td><input name='CondicaoPagamento' value='" & myDataReader("CondicaoPagamento") & "'></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Prazo de entrega:</td><td><input name='PrazoEntrega' value='" & myDataReader("PrazoEntrega") & "'></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Desconto:</td><td><input name='Desconto' value='" & myDataReader("Desconto") & "'></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Faturado:</td>"
                Painel.Text = Painel.Text & "<td><select name='Faturado'>"
                Painel.Text = Painel.Text & "<option value='true'" & iif(myDataReader("Faturado"), " selected", "") & ">Sim</option>"
                Painel.Text = Painel.Text & "<option value='false'" & iif(not myDataReader("Faturado"), " selected", "") & ">Não</option>"
                Painel.Text = Painel.Text & "</select></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Cancelado:</td>"
                Painel.Text = Painel.Text & "<td><select name='Cancelado'>"
                Painel.Text = Painel.Text & "<option value='true'" & iif(myDataReader("Cancelado"), " selected", "") & ">Sim</option>"
                Painel.Text = Painel.Text & "<option value='false'" & iif(not myDataReader("Cancelado"), " selected", "") & ">Não</option>"
                Painel.Text = Painel.Text & "</select></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Total:</td><td><input name='Total' value='" & Format(myDataReader("Total"), "#.00") & "'></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Observação:</td><td><textarea name='Observacao' rows='5' cols='30'>" & myDataReader("Observacao") & "</textarea></td></tr>"
            Painel.Text = Painel.Text & "<tr><td><input type='submit' value='Alterar'></td><td><input type='button' value='Cancelar' onClick='vbscript:cancelar()'></td></tr>"
            Painel.Text = Painel.Text & "</table></form>"
            myDataReader.Close()
        case else:
            Painel.Text = "<h3>Inserir:</h3><form method='post' action='pedidoexibiralterar.aspx'><input type='hidden' name='acao' value='inserir'><table border='0' cellspacing='0' cellpadding='4'>"
            Painel.Text = Painel.Text & "<tr><td>Código Jolitex:</td><td><input name='CodigoJolitex'></td></tr>"
            cmd.CommandText = "select id, razaosocial from cliente order by razaosocial asc"
            dr = cmd.ExecuteReader()
            Painel.Text = Painel.Text & "<tr><td>Cliente:</td><td><select name='IDCliente'>"
                while dr.Read()
                    Painel.Text = Painel.Text & "<option value='" & dr("id") & "'>" & dr("razaosocial") & "</option>"
                End while
            Painel.Text = Painel.Text & "</select></td></tr>"
            dr.Close()
    
            cmd.CommandText = "select id, nome from vendedor order by nome asc"
            dr = cmd.ExecuteReader()
            Painel.Text = Painel.Text & "<tr><td>Vendedor:</td><td><select name='IDVendedor'>"
                while dr.Read()
                    Painel.Text = Painel.Text & "<option value='" & dr("id") & "'>" & dr("nome") & "</option>"
                End while
            Painel.Text = Painel.Text & "</select></td></tr>"
            dr.Close()
    
            cmd.CommandText = "select id, razaosocial from fabrica order by razaosocial asc"
            dr = cmd.ExecuteReader()
            Painel.Text = Painel.Text & "<tr><td>Fábrica:</td><td><select name='IDFabrica'>"
                while dr.Read()
                    Painel.Text = Painel.Text & "<option value='" & dr("id") & "'>" & dr("razaosocial") & "</option>"
                End while
            Painel.Text = Painel.Text & "</select></td></tr>"
            dr.Close()
    
            cmd.CommandText = "select id, razaosocial from transportadora order by razaosocial asc"
            dr = cmd.ExecuteReader()
            Painel.Text = Painel.Text & "<tr><td>Transportadora:</td><td><select name='IDTransportadora'>"
                while dr.Read()
                    Painel.Text = Painel.Text & "<option value='" & dr("id") & "'>" & dr("razaosocial") & "</option>"
                End while
            Painel.Text = Painel.Text & "</select></td></tr>"
            dr.Close()
    
            Painel.Text = Painel.Text & "<tr><td>Data:</td><td><input name='Data' value='" + DateTime.Now.ToShortDateString() + "'></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Cond. pagamento:</td><td><input name='CondicaoPagamento'></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Prazo de entrega:</td><td><input name='PrazoEntrega'></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Desconto:</td><td><input name='Desconto'></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Faturado:</td>"
                Painel.Text = Painel.Text & "<td><select name='Faturado'>"
                Painel.Text = Painel.Text & "<option value='true'>Sim</option>"
                Painel.Text = Painel.Text & "<option value='false' selected>Não</option>"
                Painel.Text = Painel.Text & "</select></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Cancelado:</td>"
                Painel.Text = Painel.Text & "<td><select name='Cancelado'>"
                Painel.Text = Painel.Text & "<option value='true'>Sim</option>"
                Painel.Text = Painel.Text & "<option value='false' selected>Não</option>"
                Painel.Text = Painel.Text & "</select></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Total:</td><td><input name='Total' ></td></tr>"
            Painel.Text = Painel.Text & "<tr><td>Observação:</td><td><textarea name='Observacao' rows='5' cols='30'></textarea></td></tr>"
            Painel.Text = Painel.Text & "<tr><td><input type='submit' value='Inserir'></td><td><input type='reset' value='Limpar'></td></tr>"
            Painel.Text = Painel.Text & "</table></form>"
        End Select
    
        myConnection.Close()
    End Sub

</script>
<html>
<head>
    <script language="vbscript">
    sub confirma(num)
        if msgbox("Confirmar exclus?o?", vbYesNo) = vbYes then
            document.aux.idproduto.value = num
            document.aux.submit
        end if
    end sub

    sub cancelar()
        document.alterar.acao.value = "exibir"
        document.alterar.submit
    end sub
</script>
</head>
<body style="FONT-FAMILY: arial">
    <table bordercolor="navajowhite" cellspacing="0" cellpadding="2" width="950" align="center" bgcolor="floralwhite">
        <tbody>
            <tr>
                <td valign="center" align="middle" bgcolor="#ffdead" colspan="2">
                    <h2>Pedido 
                    </h2>
                </td>
            </tr>
            <tr>
                <td valign="top">
                    <asp:Label id="Painel" runat="server"></asp:Label></td>
            </tr>
        </tbody>
    </table>
</body>
</html>
